<%@page import="com.student.page.Page"%>
<%@page import="com.student.entity.Student"%>
<%@page import="java.util.ArrayList"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ page errorPage="error/errorPage.jsp" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>用户信息一览表</title>
<link rel="stylesheet" type="text/css" href="page/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="page/css/zzsc-demo.css">
<link rel="stylesheet" type="text/css" href="page/css/style.css" />
<link rel="stylesheet" type="text/css" href="page/css/style_1.css" />
<link rel="stylesheet" type="text/css" href="page/css/basictable.css" />
<script type="text/javascript" src="page/js/jquery.min.js"></script>
<script type="text/javascript" src="page/js/bootstrap.min.js"></script>
<style type="text/css">
body{width: 100%;height: 100%;background-color: rgb(226,219,190);}

.modal-body p{border-bottom: 1px solid rgb(86,162,207);}
.modal-body p strong{width: 45%;display: inline-block;}
.modal-body p span{font-weight: bold;display: inline-block;font-family: "Consolas";color: blue;letter-spacing: 1px;font-size: 15px;}

#chenkbox {position: relative;}
table {table-layout: fixed;}
th {cursor: pointer;}
span.code{border-radius: 6%;padding: 4px 5px;opacity: 0.7;}
span.code{background: rgb(255,83,77);display: inline-block;}
span.code1{background: rgb(37,198,252);}  
span.code:hover{opacity: 1.0;}

</style>
</head>
<body>

</head>
<body>

<% String user=(String) session.getAttribute("user");
//System.out.print(user);
if(user==null){
	response.sendRedirect("error/needLogin.html");
}else{
%>
<%
	StringBuffer sname=(StringBuffer) request.getAttribute("sname");
	request.setCharacterEncoding("utf-8");
	Page p=(Page) request.getAttribute("pageStu");
	//ArrayList<Student> students=(ArrayList<Student>) request.getAttribute("Students");
	if(p==null){
		//request.getRequestDispatcher("../selectStudentsServlet");
		//out.print("nothing-from userList page!");
		System.out.println("nothing!--form index,jsp");
	}else{
		ArrayList<Student> students=p.getStudents();
%>	
<div class="zzsc-container">
	<div id="page">
		<div id="chenkbox">
			<div class="row clearfix">
				<div class="col-md-12 column">
					<ul class="breadcrumb">
						<li><a href="#">用户管理</a></li>
						<li class="active">用户信息一览表&nbsp;&nbsp;<span style="color: blue;"><%=p.getCurrentPage()+1 %>/<%=p.getPageTotal() %></span></li>
					</ul>
				</div>
			</div>
		<table class="two-axis" id="table">
	
		<thead><tr>
			<th onclick="sortTable('table',0)" title="点击排序" style="width: 6%;">序号</th>
			<th onclick="sortTable('table',1)" title="点击排序" style="width: 10%;">工号/学号</th>
			<th onclick="sortTable('table',2)" title="点击排序" style="width: 10%;">用户名</th>
			<th onclick="sortTable('table',3)" title="点击排序">部门/院系</th>
			<th onclick="sortTable('table',4)" title="点击排序">最近登录时间</th>
			<th onclick="sortTable('table',5)" title="点击排序" style="width: 14%;">登录地址</th>
			<th>操作</th>
		</tr></thead>
		<tbody>
		<%int count=0;
			for(Student student: students){
				
				count++;
		%>

		<tr>
			<td><%= count %></td>
			<td><%=student.getId()!=null? student.getId(): " " %></td>
			<td><%=student.getUname()!=null? student.getUname(): " " %></td>
			<td><%=student.getDepart()!= null? student.getDepart(): " " %></td>
			<td><%=student.getLoginTime()!=null? student.getLoginTime() :" " %></td>
			<td><%=student.getIp()!=null? student.getIp(): " " %></td>
			<td>
				<a href="" data-toggle="modal" data-target="#<%=count%>"><span class="code">删除信息</span></a>
				<a href="" data-toggle="modal" data-target="#m<%=count%>"><span class="code code1">查看详情</span></a>
			</td>
		</tr>
	
<!-- 模态框（Modal） -->
<div class="modal fade" id="<%=count %>" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
					&times;
				</button>
				<h4 class="modal-title" id="myModalLabel">
					请确认是否删除
				</h4>
			</div>
			<div class="modal-body">
				是否删除 <%=student.getUname() %> 的信息？
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default" data-dismiss="modal">取消
				</button>
				<a href="deleteStudentServlet?uid=<%=student.getId() %>">
					<button type="button" class="btn btn-success">确认</button>
				</a>
			</div>
		</div><!-- /.modal-content -->
	</div><!-- /.modal -->
</div>

<!-- 模态框（Modal）显示详情页 -->
<div class="modal fade" id="m<%=count %>" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
					&times;
				</button>
				<h4 class="modal-title" id="myModalLabel">
					<%=student.getUname() %> 的详细信息：
				</h4>
			</div>
			<div class="modal-body">
				<p><strong>工号/学号</strong><span><%=student.getId() %> </span></p>
				<p><strong>用户名</strong><span><%=student.getUname()!=null? student.getUname(): " " %></span></p>
				<p><strong>部门/院系</strong><span><%=student.getDepart()!=null? student.getDepart():" " %></span></p>
				<p><strong>分数</strong><span><%=student.getScore()!=0.0? student.getScore(): " " %></span></p>
				<p><strong>最近登录时间</strong><span><%=student.getLoginTime()!=null ? student.getLoginTime(): " " %></span></p>
				<p><strong>登录地址</strong><span><%=student.getIp()!=null? student.getIp(): " " %></span></p>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default" data-dismiss="modal">关闭
				</button>
				<a href="transitServlet?uid=<%=student.getId() %>">
					<button type="button" class="btn btn-success">修改</button>
				</a>
			</div>
		</div><!-- /.modal-content -->
	</div><!-- /.modal -->
</div>
<%
		}
%>
			</tbody>
		</table>
		</div>
	</div>
</div>

<div class="btn-group center-block" style="margin: 30px auto;">
    <button type="button" class="btn btn-default"><a href="getPageServlet?currentPage=0&pageCapacity=<%=p.getPageCapacity() %>">首页</a></button>
    <button type="button" class="btn btn-default"><a href="getPageServlet?currentPage=<%=(p.getCurrentPage()-1) %>&pageCapacity=<%=p.getPageCapacity() %>">上一页</a></button>
    <button type="button" class="btn btn-default"><a href="getPageServlet?currentPage=<%=(p.getCurrentPage()+1) %>&pageCapacity=<%=p.getPageCapacity() %>">下一页</a></button>
    <button type="button" class="btn btn-default"><a href="getPageServlet?currentPage=<%=p.getPageTotal()-1 %>&pageCapacity=<%=p.getPageCapacity() %>">尾页</a></button>
    <div class="btn-group">
    <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
        自定义容量
        <span class="caret"></span>
    </button>
    <ul class="dropdown-menu">
        <li><a href="getPageServlet?currentPage=<%=p.getCurrentPage() %>&pageCapacity=5">5</a></li>
        <li><a href="getPageServlet?currentPage=<%=p.getCurrentPage() %>&pageCapacity=6">6</a></li>
        <li><a href="getPageServlet?currentPage=<%=p.getCurrentPage() %>&pageCapacity=8">8</a></li>
        <li><a href="getPageServlet?currentPage=<%=p.getCurrentPage() %>&pageCapacity=9">9</a></li>
        <li><a href="getPageServlet?currentPage=0&pageCapacity=<%=p.getTotalCount() %>">显示全部</a></li>
    </ul>
    </div>
</div>

<%} %>

<!-- 模态框（Modal） -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×
				</button>
				<h4 class="modal-title btn-block" id="myModalLabel">
					添加的结果：
				</h4>
			</div>
			<div class="modal-body">
<%=sname %>
			</div>
			<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
				<a href="add.jsp" >
					<button type="button" class="btn btn-primary">
						增加
					</button>
				</a>

			</div>
		</div><!-- /.modal-content -->
	</div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<% if(sname!=null){
%>
<script type="text/javascript">
    $(function(){
         $("#myModal").modal({
            keyboard: true
        });
    });
</script>

<%
sname=null;
} %>
<script type="text/javascript" src="page/js/columnDrag.js"></script>
<script type="text/javascript" src="page/js/jquery.basictable.min.js"></script>
<script type="text/javascript">
	$(document).ready(function() {
	  $('#table').basictable();

	  $('#table-breakpoint').basictable({
		breakpoint: 768
	  });

	  $('#table-swap-axis').basictable({
		swapAxis: true
	  });

	  $('#table-force-off').basictable({
		forceResponsive: true
	  });

	  $('#table-no-resize').basictable({
		noResize: true
	  });

	  $('#table-two-axis').basictable();

	  $('#table-max-height').basictable({
		tableWrapper: true
	  });
	});
  </script>

<%
}
%>
</body>
</html>